#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    bool checkAlmostEquivalent(string word1, string word2) {
        int n = word1.size();
        if (n <= 3) return true;
        vector<int> hash1(127);
        vector<int> hash2 = hash1;
        for (auto e : word1) hash1[e - 'a']++;
        for (auto e : word2) hash2[e - 'a']++;

        for (int i = 0; i < 127; i++)
        {
            if (abs(hash1[i] - hash2[i]) > 3)
                return false;
        }
        return true;

    }
};